﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Thuoc24h.Services
{
    /// <summary>
    /// Summary description for InvoiceStatus
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class InvoiceStatus : System.Web.Services.WebService
    {

      
        
        [WebMethod]
        public string RefundOrder()
        {
            return "Hello World";
        }


        [WebMethod]
        public Boolean UpdateOrder(String transaction_info, String order_code, String payment_id, String payment_type, String secure_code)
        {
            String secure_code_ws = this.GetMD5Hash(transaction_info + " " + order_code + " " + payment_id + " " + payment_type + " " + this.secure_pass);
            if (secure_code == secure_code_ws)
                return true;
            else
                return false;
        }

        private String secure_pass = "duyhung";//Mật khẩu gia tiếp api
        public String GetMD5Hash(String input)
        {

            var x = new System.Security.Cryptography.MD5CryptoServiceProvider();

            byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);

            bs = x.ComputeHash(bs);

            var s = new System.Text.StringBuilder();

            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            String md5String = s.ToString();
            return md5String;
        }
    }
}
